package com.jerry.spring.security.jwt.controller;

import com.jerry.spring.security.jwt.domain.ResponseResult;
import com.jerry.spring.security.jwt.domain.vo.LoginReqVo;
import com.jerry.spring.security.jwt.domain.vo.LoginRespVo;
import com.jerry.spring.security.jwt.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 登录
 *
 * @author jerry 2024/5/9 14:08
 */
@RestController
@RequestMapping("/user")
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 登录接口
     *
     * @return
     */
    @PostMapping("/login")
    public ResponseResult<LoginRespVo> login(@RequestBody LoginReqVo vo) {
        return ResponseResult.ok(loginService.login(vo));
    }

    /**
     * 注销接口
     *
     * @return
     */
    @PostMapping("/logout")
    public ResponseResult<Object> logout() {
        loginService.logout();
        return ResponseResult.ok("注销成功");
    }
}
